<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<p>This tests triple clicking after the last character in the last cell of a
block table. The paragraph break (the space between the last character and the
first character in the next paragraph) should be selected. Selection painting
problems might prevent the paragraph break from appearing as selected even
though it is. To test manually, triple click inside the table cell, after the
last character, and hit delete.  Afterward, the table should contain only 'bar'.
</p>
<div contenteditable="true">
<table border="1"><tr><td width="100px"><span id="span">foo</span></td></tr></table>
<div id="end">bar</div>
</div>
<div id="log"></div>
<script>
test(function() {
    var selection = window.getSelection();

    span = document.getElementById("span");
    x = span.offsetParent.offsetLeft + span.offsetLeft + span.offsetWidth + 10;
    y = span.offsetParent.offsetParent.offsetTop + span.offsetParent.offsetTop + span.offsetTop + span.offsetHeight / 2;

    if (!window.internals && !window.eventSender)
        return;
    internals.settings.setEditingBehavior('win');

    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();
    eventSender.mouseUp();
    eventSender.mouseDown();
    eventSender.mouseUp();
    eventSender.mouseDown();
    eventSender.mouseUp();

    assert_false(selection.isCollapsed, 'isCollapsed');
    assert_equals(selection.anchorNode, span.firstChild, 'anchorNode');
    assert_equals(selection.anchorOffset, 0, 'anchorOffset');
    assert_equals(selection.focusNode, document.getElementById('end'), 'focusNode');
    assert_equals(selection.focusOffset, 0, 'focusOffset');
});
</script>
